﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApplication1.Modulators
{
    public class Autopilot
    {
        public static Random random = new Random();
        public static void modulateAltitude(Models.Aircraft aircraft)
        {
            aircraft.desired_elevator = aircraft.elevator;
            //if (aircraft.altitude < 2000)
            //{
            //    if (aircraft.pitchAngle > 40)
            //    {
            //        if (aircraft.elevator < 0.3)
            //        {
            //            aircraft.desired_elevator += 0.01f;
            //        }
            //    }
            //    else if (aircraft.pitchAngle < 40)
            //    {
            //        if (aircraft.elevator > -0.3)
            //        {
            //            aircraft.desired_elevator -= 0.01f;
            //        }
            //    }
            //}
            //else if (aircraft.altitude > 2000)
            //{
            //    if (aircraft.pitchAngle < 0)
            //    {
            //        if (aircraft.elevator > -0.3)
            //        {
            //            aircraft.desired_elevator -= 0.001f;
            //        }
            //    }
            //    else if (aircraft.pitchAngle > 0)
            //    {
            //        if (aircraft.elevator < -0.3)
            //        {
            //            aircraft.desired_elevator += 0.001f;
            //        }
            //    }
            //}
        }
        public static void modulateRoll(Models.Aircraft aircraft)
        {
            if (aircraft.bankAngle < 0)
            {
                if (aircraft.aileron < 0.3)
                {
                    aircraft.desired_aileron += 0.01f;
                }
            }
            else if (aircraft.bankAngle > 0)
            {
                if (aircraft.aileron > -0.3)
                {
                    aircraft.desired_aileron -= 0.01f;
                }
            }
        }

        public static void modulateYaw(Models.Aircraft aircraft)
        {

        }

        public static void modulate(Models.Aircraft aircraft)
        {
            //modulateAltitude(aircraft);
            //modulateRoll(aircraft);
            modulateYaw(aircraft);
        }
    }
}
